/**
* @file 添加附件
* @author  zhoushu
* @date  17/1/12
*/
<template>
  <div class="add-file" v-show="(addfile && addfile.length>0) || (folder && folder.length>0)">
    <ul class="mui-table-view">
      <p class="add_company_des">附件</p>
      <div class="add_company_file">
        <li @tap="clickFolder(list)" v-for="list in folder" class="mui-navigate-right"><span
          class="mui-icon mui-icon-folder"></span>{{list.name}}
        </li>
        <li style="margin: 0;" v-for="list in addfile" class="mui-table-view-cell theRightAddFile">
          <div style="line-height: 24px;" :class="{'mui-slider-handle': list.fileIds}"
               @tap="clickAdd(list,$event)">
                  <span class="iconFamily fileIcons" :class="{
                 'fileTypeWork': getFileType(list.type) == 0,
                 'fileTypeExl':getFileType(list.type) == 1,
                 'fileTypePpt':getFileType(list.type) == 2,
                 'fileTypePdf':getFileType(list.type) == 3,
                 'mui-icon-addFile':getFileType(list.type) == 4}"></span>
            {{list.name}}
          </div>
          <div class="mui-slider-right mui-disabled">
            <a class="mui-btn mui-btn-red" @click="clickDelete(list,$event,$index)">删除</a>
          </div>
        </li>
      </div>
    </ul>
  </div>
</template>
<script>
  // import store from '../store';
  export default{
    props: {
      folder: [],  //  显示的文件夹
      addfile: [] //  可以添加的附件
    },
    methods: {
      getFileType: function (type) {
        if (type === '.doc' || type === '.docx') {
          return 0;
        } else if (type === '.xlsx' || type === '.xls') {
          return 1;
        } else if (type === '.pptx' || type === '.ppt') {
          return 2;
        } else if (type === '.pdfx' || type === '.pdf') {
          return 3;
        } else {
          return 4;
        }
      },
      clickFolder: function (item) {
        this.$dispatch('clickFolder', item);
      },
      clickAdd: function (item, event) {
        this.$dispatch('clickAdd', item, event);
      },
      clickDelete: function (item, event, index) {
        this.$dispatch('clickDelete', item, event, index);
      }
    },
    created: function () {
    },
    route: {
      data: function () {
      }
    },
    ready: function () {
    }
  };
</script>
